import { useRouteStore } from '@/store/route'

export default () => {
  const routeStore = useRouteStore()

  const menuRoute = routeStore.menuRoute

  // 处理一级路由
  const newArr = menuRoute.map((item) => {
    item.titles = [item.title]
    return item
  })

  // 处理 titles 里面的 二级路由
  menuRoute.forEach((item) => {
    if (item.children.length) {
      item.children.forEach((childItem) => {
        childItem.titles = item.titles.concat(childItem.title)
      })

      newArr.push(...item.children)
    }
  })

  return newArr
}
